// 密码显示隐藏
var passwd = document.querySelectorAll('.ps');
var eye = document.querySelectorAll('.eye');

eyes(eye[0], passwd[0]);
eyes(eye[1], passwd[1]);

function eyes(eye1, pass1) {
	var flag = true;
	eye1.onclick = function() {
		if (flag) {
			pass1.type = 'text';
			this.className = 'icon-Group-';
			this.innerHTML = '&#xe6a2;';
			flag = false;
		} else {
			pass1.type = 'password';
			this.className = 'icon-yincang';
			this.innerHTML = '&#xe85f;';
			flag = true;
		}
	}
}

// 获取提示
var yanZheng = document.querySelectorAll('em');

// 验证用户名
var uname = document.querySelector('.uname');
var unameReg = /^[a-zA-Z]\w*$/;

// 验证密码
var pass = document.querySelectorAll('.ps');
var passReg = /^[a-zA-Z0-9][a-zA-Z0-9_!+#@]{5,17}$/;

// 验证手机号
var tell = document.querySelector('.tel');
var tellReg = /^(13[0-9]|14[5|7]|15[0-9]|16[6]|17[3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9]|19[8|9])\d{8}$/;

// 验证邮箱
var email = document.querySelector('.email1');
var emailReg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;

regExp(uname,unameReg,yanZheng[0]);
regExp(pass[0],passReg,yanZheng[1]);
regExp(tell,tellReg,yanZheng[3]);
regExp(email,emailReg,yanZheng[4]);

function regExp (ele,reg,yz) {
	ele.onblur = function () {
		if (reg.test(ele.value)) {
			yz.className = 'icon-zhengque';
			yz.innerHTML = '&#xe652;';
			yz.style.color = 'greenyellow';
		}else {
			yz.className = 'icon-cuowu';
			yz.innerHTML = '&#xe60c;';
			yz.style.color = 'red';
		}
	}
}

pass[1].onblur = function () {
	if (pass[1].value == pass[0].value) {
		yanZheng[2].className = 'icon-zhengque';
		yanZheng[2].innerHTML = '&#xe652;';
		yanZheng[2].style.color = 'greenyellow';
	}else {
		yanZheng[2].className = 'icon-cuowu';
		yanZheng[2].innerHTML = '&#xe60c;';
		yanZheng[2].style.color = 'red';
	}
}